package ru.papergames.battleserver.network.clientpackets.flashuser;

import org.apache.log4j.Logger;
import ru.papergames.battleserver.model.PaperGameFlashUser;
import ru.papergames.battleserver.model.battle.AbstractBattle;
import ru.papergames.battleserver.model.battle.BattlePlayer;

/**
 * @author: atroshanin
 * Date: 14.04.2010
 * Time: 22:52:42
 */
public class ClientLoadedBattle extends PaperGameClientPacket {

    private static final Logger log = Logger.getLogger(ClientLoadedBattle.class.getName());

    @Override
    protected void readImpl() {
    }

    @Override
    protected void runImpl() {
        PaperGameFlashUser user = getClient().getUser();
        AbstractBattle battle = user.getBattle();
        BattlePlayer member = user.getBattleMember();
        if (battle != null && member != null) {
            member.setBattleLoaded(true);
        }
        if (log.isDebugEnabled()) {
            log.debug("Player[" + user.getId() + "] loaded battle");
        }
    }

    @Override
    public String getType() {
        return "[c] ClientLoadedBattle[" + CLIENT_LOADED_BATTLE_PACKET_ID + "]";
    }
}
